/* 
 * File:   VectorToScalarDataset.cpp
 * Author: cjjonker
 * 
 * Created on 4 januari 2013, 16:57
 */

#include "VectorToScalarDataset.h"
#include "Vector.h"
#include <cmath>
#include "Utilities.h"


VectorToScalarDataset::VectorToScalarDataset(VectorDataset* set)
:
d_type(Magnitude)
{
    d_dataset = set;
    d_dim = set->dim();
}

VectorToScalarDataset::VectorToScalarDataset(VectorDataset* set, Type t)
:
d_type(t)
{
    d_dataset = set;
    d_dim = set->dim();
}


double VectorToScalarDataset::getData(int idx, int t)
{
    switch (d_type)
    {
        case Magnitude:
            return getVectorData(idx, t).length();
            break;
            
        case Angle:
            if (getVectorData(idx, t).length()==0) {
                return 0;
            }
            //std::cout << rad2deg(atan2(getVectorData(idx).x, getVectorData(idx).y)) << " ";
            return rad2deg(atan2(getVectorData(idx).x, getVectorData(idx).y));
            break;
            
        default:
            d_type = Magnitude;
            return getVectorData(idx, t).length();
            break;
    }
    
}


double VectorToScalarDataset::getMin(int t_depth, int slice_dt) 
{
    switch (d_type)
    {
        case Magnitude:
            return ScalarDataset::getMin(t_depth, slice_dt);
            break;    
        case Angle:
            return -180.0;
            break;
        default:
            d_type = Magnitude;
            return ScalarDataset::getMin(t_depth, slice_dt);
            break;
    }
}

double VectorToScalarDataset::getMax(int t_depth, int slice_dt)
{
    switch (d_type)
    {
        case Magnitude:
            return ScalarDataset::getMax(t_depth, slice_dt);
            break;    
        case Angle:
            return 180.0;
            break;
        default:
            d_type = Magnitude;
            return ScalarDataset::getMax(t_depth, slice_dt);
            break;
    }
}



